package com.ruoyi.biz.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.biz.domain.BizSubmitWork;
import com.ruoyi.biz.service.IBizSubmitWorkService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 作业提交Controller
 * 
 * @author lhb
 * @date 2025-02-24
 */
@RestController
@RequestMapping("/biz/submitWork")
public class BizSubmitWorkController extends BaseController
{
    @Autowired
    private IBizSubmitWorkService bizSubmitWorkService;

    /**
     * 查询作业提交列表
     */
    @PreAuthorize("@ss.hasPermi('biz:submitWork:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizSubmitWork bizSubmitWork)
    {
        startPage();
        List<BizSubmitWork> list = bizSubmitWorkService.selectBizSubmitWorkList(bizSubmitWork);
        return getDataTable(list);
    }

    /**
     * 导出作业提交列表
     */
    @PreAuthorize("@ss.hasPermi('biz:submitWork:export')")
    @Log(title = "作业提交", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizSubmitWork bizSubmitWork)
    {
        List<BizSubmitWork> list = bizSubmitWorkService.selectBizSubmitWorkList(bizSubmitWork);
        ExcelUtil<BizSubmitWork> util = new ExcelUtil<BizSubmitWork>(BizSubmitWork.class);
        util.exportExcel(response, list, "作业提交数据");
    }

    /**
     * 获取作业提交详细信息
     */
    @PreAuthorize("@ss.hasPermi('biz:submitWork:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizSubmitWorkService.selectBizSubmitWorkById(id));
    }

    /**
     * 新增作业提交
     */
    @PreAuthorize("@ss.hasPermi('biz:submitWork:add')")
    @Log(title = "作业提交", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizSubmitWork bizSubmitWork)
    {
        return toAjax(bizSubmitWorkService.insertBizSubmitWork(bizSubmitWork));
    }

    /**
     * 修改作业提交
     */
    @PreAuthorize("@ss.hasPermi('biz:submitWork:edit')")
    @Log(title = "作业提交", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizSubmitWork bizSubmitWork)
    {
        return toAjax(bizSubmitWorkService.updateBizSubmitWork(bizSubmitWork));
    }

    /**
     * 删除作业提交
     */
    @PreAuthorize("@ss.hasPermi('biz:submitWork:remove')")
    @Log(title = "作业提交", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizSubmitWorkService.deleteBizSubmitWorkByIds(ids));
    }
}
